<?php
	
class LogView{
		
		/**
		 * Public function to display errormessages with html
		 * @param -
		 * @return string HTML
		 */	
		public function showErrors(){
			$errorArray = LogHandler::$errorArray;
			$errors = "<h2>Errors:</h2>";
			foreach($errorArray as $key => $error){
				$errors .= "<p style='color:red'>$error</p>";
			}	
			return $errors;
		}
		
		/**
		 * Public function to display all messages (errors and non-errors) with html
		 * @param -
		 * @return string HTML
		 */	
		public function showAllMessages(){
			
			$returnDiv = "<div><h1>Logged Messages:</h1>";
			
			$returnDiv .= $this->showErrors();
			
			$returnDiv .= "<h2>Non errors:</h2>";
			
			$messageArray = LogHandler::$messageArray;
			
			foreach($messageArray as $key => $message){
				$returnDiv .= "<p style='color:green'>$message</p>";
			}
				
			$returnDiv .= "
					</div>";
					
			return $returnDiv;
		}
		
		
		public function logTester(){
			//No messages should be shown
			echo "<h1>No messages should be displayed:</h1>";
			echo $this->showAllMessages();
			
			//Log messages
			LogHandler::logMessage("First Message test");
			LogHandler::logError("First Error test, Something whent wrong");
			
			echo "<h1>One message and one error to display:</h1>";
			echo $this->showAllMessages();
			
			//Log messages
			LogHandler::logMessage("Message test again");
			LogHandler::logError("Error test again");
			
			echo $this->showAllMessages();
			echo $this->showErrors();
		}
	}